package com.ai.langchain4jchat.controller;

import com.ai.langchain4jchat.aiservice.AssistantService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

@RestController
public class ChatController {
    @Autowired
    private AssistantService assistantService;

    /*@RequestMapping("/chat")
    public String chat(String message) {
        // 调用ChatService的chat方法
        return assistantService.chat(message);
    }*/

    /*@Autowired
    private OpenAiChatModel model;
    @RequestMapping("/chat")
    public String chat(String message) {
        return model.chat(message);
    }*/

    /*@RequestMapping(value = "/chat", produces = "text/html;charset=utf-8")
    public Flux<String> chat(@RequestParam String message) {
        // 调用ChatService的chat方法
        return assistantService.chat(message);
    }*/

    @RequestMapping(value = "/chat", produces = "text/html;charset=utf-8")
    public Flux<String> chat(@RequestParam String memoryId, @RequestParam String message) {
        // 调用ChatService的chat方法
        return assistantService.chat(memoryId, message);
    }
}
